using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(CharacterController))]
public class move : MonoBehaviour
{
    public float speed, x, z, y;
    [SerializeField] private CharacterController palyercontroller;

    void Start()
    {
        palyercontroller = GetComponent<CharacterController>();
    }

    void Update()
    {
        x = Input.GetAxis("Horizontal");
        z = Input.GetAxis("Vertical");

        Vector3 move;

        move = transform.right * x + transform.forward * z + transform.up * y;

        palyercontroller.Move(move * speed * Time.deltaTime);

        if (Input.GetKey(KeyCode.LeftShift))
        {
            speed = 15;
        }
        else 
        {
            speed = 5;
        }

        if (Input.GetKey(KeyCode.Space))
        {
            y = 4;
        }
        else
        {
            y = -1;
        }
    }
}
